<template>
  <view class="recommend_content">
    <div class="col2Img" v-if="wholeEnableConfig && showWholeRecommend">
      <h6>推荐搭配</h6>
      <div class="goodsList">
        <block v-for="(item, index) in recommendWhole" :key="index">
          <div class="gItem" :data-itemId="item.itemId? item.itemId : item.entityId"
            :data-skuCodes="item.skuCodes[0]? item.skuCodes : item.sku" :data-valueId="item.valueId? item.valueId : '' "
            :data-valueName="item.valueName? item.valueName : item.name" :data-classId="item.classId "
            @click="jumpPage">
            <image class="img" mode="widthFix" :src="item.majorUrl? item.majorUrl : item.defaultImagePath"></image>
            <view class="name">{{item.itemName? item.itemName : item.name}}</view>
            <p class="color">
              <block v-for="(itemcolor, index) in item.frontProperties" :key="index">
                <image mode="widthFix" :src="itemcolor.skuImageUrl"></image>
              </block>
            </p>

            <view class="recommendPrice">
              <!--        <block v-if="item.specialPrice / 1 > item.price /1">
		            <view class="linePrice">{{ "¥ " + item.specialPrice / 1 }}</view>
		            <view class="nowPrice">{{  "¥ " +  item.price / 1}}</view>
		          </block>
              <view v-else>
		          </view> -->
              <view class="price">{{ "¥ " + item.price / 1}}</view>
            </view>
            <view class="markPrice rule-price-box" v-if="item.rulesArr.length > 0">
              <block v-for="(innerItem, innerIndex) in item.rulesArr" :key="innerIndex">
                <view class="rule-price goodsTag">{{ innerItem.priceTag}} {{ '¥ ' + innerItem.strategyPrice}}</view>
              </block>
            </view>

          </div>
        </block>
      </div>
    </div>
    <div class="col2Img" v-if="smilarEnableConfig && recommendSimilar.length > 0">
      <h6>同类商品</h6>
      <div class="goodsList">
        <block v-for="(item, index) in recommendSimilar" :key="index">
          <div class="gItem" :data-itemId="item.itemId? item.itemId : item.entityId"
            :data-skuCodes="item.skuCodes[0]? item.skuCodes : item.sku" :data-valueId="item.valueId? item.valueId : '' "
            :data-valueName="item.valueName? item.valueName : item.name" :data-classId="item.classId "
            @click="jumpPage">
            <image class="img" mode="widthFix" :src="item.majorUrl"></image>
            <view class="name">{{item.itemName}}</view>
            <p class="color">
              <block v-for="(itemcolor, index) in item.frontProperties" :key="index">
                <image mode="widthFix" :src="itemcolor.skuImageUrl"></image>
              </block>
            </p>

            <view class="recommendPrice">
              <block v-if="item.markingPrice / 1 > item.price /1">
                <view class="linePrice">{{ "¥ " + item.markingPrice / 1 }}</view>
                <view class="nowPrice">{{ "¥ " +  item.price / 1}}</view>
              </block>
              <view v-else>
                <view class="price">{{ "¥ " + item.price / 1}}</view>
              </view>
            </view>
            <view class="markPrice rule-price-box" v-if="item.rulesArr.length > 0">
              <block v-for="(innerItem, innerIndex) in item.rulesArr" :key="innerIndex">
                <view class="rule-price goodsTag">{{ innerItem.priceTag}} {{ '¥ ' + innerItem.strategyPrice}}</view>
              </block>
            </view>
          </div>
        </block>
      </div>
    </div>

    <view class="mos" v-if="ugcEnableConfig && showUGCRecommend">
      <!-- Me &Other Stories （UGC用户自定义模块） -->
      <!-- <view class="title">
		    <image src="https://efc-stories-assets-1252208446.cos.ap-shanghai.myqcloud.com/miniprogram/images/mos_title_02.jpg" style="width: 100%;" mode="widthFix"></image>
		  </view>
		  <view class="pView">
		    在微信小程序订购的商品不可在实体门店进行退货。非商品质量问题的退货需由顾客承担所产生的运费。
		  </view> -->
      <view class="imgView">
        <!-- <block v-for="(item, index) in recommendUGC" :key="index">
		      <view class="item">
		        <image :src="item.majorUrl" style="width: 100%;" mode="aspectFill"></image>
		      </view>
		    </block> -->

        <swiper indicator-dots="false" autoplay="true" interval="5000" duration="500" indicator-active-color="#444"
          indicator-color="#efefef" class="swiper" @change="swiperChange" style="height: 1040rpx; width: 100%;">
          <block v-for="(item, index) in recommendUGC" :key="index">
            <swiper-item>
              <image :src="item.majorUrl" :data-src="item.majorUrl" class="slide-image" />
            </swiper-item>
          </block>
        </swiper>

      </view>
    </view>
  </view>
</template>

<script>
  import {
    SYSTEM_INFO,
    MERCHANT_INFO,
    USER_INFO,
    USER_SPECICAL_INFO,
    CUSTOMER_INFO,
    CART_KEY
  } from '@/utils/constant';
  import tip from '@/utils/tip';
  import util from '@/utils/util';
  import api from '@/api/api';

  export default {
    props: {
      goodsId: Number,
      valueId: Number,
      classId: Number,
    },


    data() {
      return {
        // 模块   pdp、cart
        recommendModule: '',

        // 推荐商品
        showWholeRecommend: false,
        wholeEnableConfig: false, // 整体推荐后台配置启用
        wholeNumberConfig: 0,

        showSmilarRecommend: false,
        smilarEnableConfig: false,
        smilarNumberConfig: 0,

        d_similarvalue: 0, //同类商品数量
        recommendList: [],
        recommendSimilar: [], //同类商品
        recommendWhole: [], //推荐搭配
        recommendNum: 0, //推荐数量
        recommendType: '', //推荐类型
        access_key: '6st-gVY3GbptpFkUMQ0kjh67F5iMMnpP-9t_IhLNmnvC4RusNUWvaPx0-B4YOP_0',

        // Me & Other Stories (UGC用户自定义内容)
        showUGCRecommend: false,
        ugcEnableConfig: false,

        recommendUGC: [],

        ccCode: '',
        detail: {},
        classIdArr: [],
      }
    },


    created() {},

    mounted() {},

    watch: {
      goodsId: function(newVal, oldVal) {
        this.goodsId = newVal;
      },

      valueId: function(newVal, oldVal) {
        this.valueId = newVal;
      },

      classId: function(newVal, oldVal) {
        this.classId = newVal;
      },

    },


    methods: {
      swiperChange(e) {
        this.currentIndex = e.detail.current;
      },

      // 获取搭配推荐商品 和 UGC数据 （推荐类型）
      getRecommendItem: async function(ccCode, classIdArr, itemDetail, recommendModule = '') {
        let that = this;
        that.classIdArr = classIdArr;
        that.ccCode = ccCode;
        that.detail = itemDetail;
        that.recommendModule = recommendModule;
        if (that.recommendModule != '' && recommendModule == 'pdp' || recommendModule == 'cart') {
          let uuid = uni.getStorageSync('uuid') || '';
          if (uuid == null || uuid == undefined || uuid == '') {
            that.recommendWrite('user', uuid, ccCode, classIdArr, itemDetail);
          } else {
            that.recommendWrite('item', uuid, ccCode, classIdArr, itemDetail);
            that.recommendWrite('userVItem', uuid, ccCode, classIdArr, itemDetail);
          }
          let customerInfo = uni.getStorageSync('customerInfo');
          let merchantInfo = uni.getStorageSync(MERCHANT_INFO);
          let memberDetails = uni.getStorageSync('memberDetails') || getApp().globalData.memberDetails
          let recommendInfo = await api.getRecommendItem({
            method: 'GET',
            query: {
              group_id: customerInfo.groupId || 0,
              member_level_id: memberDetails.memberLevelId || 0,
              member_status: memberDetails.isActive || 'Inactive'
            }
          }, merchantInfo.cloudMerchantId, merchantInfo.cloudMerchantStoreId, this.goodsId, this.valueId)
          if (recommendInfo.code == 1000) {
            that.recommendConfigValueNew();
            that.recommendConfigValue();

            if (recommendInfo.data.total > 0) {
              that.recommendList = recommendInfo.data.content;

              var s_item = [];
              for (var i in that.recommendList) {
                s_item = that.recommendList[i];
                if (!!s_item.strategies) {
                  let result = await getApp().priceRulesDeal(s_item.strategies)
                  if (result.price !== 0) {
                    s_item.price = result.price
                  }
                  if (result.rulesArr.length > 0) {
                    s_item.rulesArr = result.rulesArr
                  }
                }
                if (s_item['recommendBlock'] == 'similar') {
                  that.recommendSimilar.push(s_item)
                }

                if (s_item['recommendBlock'] == 'whole') {
                  that.recommendWhole.push(s_item)
                }

                // UGC模块
                if (s_item['recommendBlock'] == 'ugc') {
                  that.recommendUGC.push(s_item)
                }

              }

              if (that.recommendUGC.length > 0) {
                that.showUGCRecommend = true;
              }
            } else {
              that.recommendList = recommendInfo.data.total;
            }
          }
        }
      },

      // 写入类别（item、user(获取uuid)、userVItem）
      recommendWrite: async function(type, uuid, ccCode, classIdArr, itemDetail) {
        let that = this;

        let merchantInfo = uni.getStorageSync(MERCHANT_INFO);
        let store_id = merchantInfo.cloudMerchantStoreId;
        let writeData = '' || {};

        if (type == 'user') {
          writeData = 'uuid';
          let writeType = type;
          let writerItem = await api.getRecommendwriter({
            header: {
              "content-type": "application/x-www-form-urlencoded",
            },
            method: 'POST',
            query: {
              "access_key": that.access_key,
              "store_id": store_id,
              "type": writeType,
              "data": JSON.stringify(writeData)
            }
          })
          if (writerItem.code === 1) {
            if (type == 'user') {
              uni.setStorageSync('uuid', writerItem.data.uuid);
              let uuid = writerItem.data.uuid;
              that.recommendWrite('item', uuid, ccCode, classIdArr, itemDetail);
              that.recommendWrite('userVItem', uuid, ccCode, classIdArr, itemDetail);
            }
          }
        } else {
          if (type == 'item') {
            writeData = {
              "pid": ccCode,
              "category_ids": classIdArr,
              "title": itemDetail.itemName,
            }
          } else if (type == 'userVItem') {
            writeData = {
              "pid": ccCode,
            }
          }

          let writeType = type;
          let writerItem = await api.getRecommendwriter({
            header: {
              "content-type": "application/x-www-form-urlencoded",
              "uuid": uuid,
            },
            method: 'POST',
            query: {
              "access_key": that.access_key,
              "store_id": store_id,
              "type": writeType,
              "data": JSON.stringify(writeData)
            }
          })
          if (writerItem.code === 1) {
          }
        }

      },


      // 获取推荐类型   推荐板块：recommend/plate   推荐位置：recommend/position   推荐商品数量：recommend/number
      recommendConfigValue: async function() {
        var that = this;
        // let merchantInfo = uni.getStorageSync(MERCHANT_INFO);
        // const recommendConfigValue = await api.getRecommendConfigValue({
        //   method: 'GET',
        //   query: {
        //     'config_client_id': 'efcloud',
        //     'config_path': 'recommend/plate',
        //     'config_scope': 'Store',
        //     'config_scope_id':merchantInfo.cloudMerchantStoreId,
        //     'merchant_id':merchantInfo.cloudMerchantId
        //   }
        // })
        // if(recommendConfigValue.code == 1000){
        //   that.recommendType = recommendConfigValue.data.value;

        //   that.recommendConfigNum()
        // }else {
        // }

      },

      // 重写 获取推荐类型
      // 是否启用整体搭配 recommend/pdp/whole_enable  整体搭配推荐商品数 recommend/pdp/whole_number
      // 是否启用同类推荐 recommend/pdp/similar_enable 同类推荐商品数 recommend/pdp/similar_number
      // 是否启用UGC recommend/pdp/ugc_enable  UGC推荐商品数 recommend/pdp/ugc_number
      recommendConfigValueNew: async function() {
        var that = this;
        let merchantInfo = uni.getStorageSync(MERCHANT_INFO);
        const wholeEnableParams = {
          method: 'GET',
          query: {
            'config_client_id': 'efcloud',
            'config_path': 'recommend/' + that.recommendModule + '/whole_enable',
            'config_scope': 'Store',
            'config_scope_id': merchantInfo.cloudMerchantStoreId,
            'merchant_id': merchantInfo.cloudMerchantId
          }
        };

        const similarEnableParams = {
          method: 'GET',
          query: {
            'config_client_id': 'efcloud',
            'config_path': 'recommend/' + that.recommendModule + '/similar_enable',
            'config_scope': 'Store',
            'config_scope_id': merchantInfo.cloudMerchantStoreId,
            'merchant_id': merchantInfo.cloudMerchantId
          }
        };

        const ugcEnableParams = {
          method: 'GET',
          query: {
            'config_client_id': 'efcloud',
            'config_path': 'recommend/' + that.recommendModule + '/ugc_enable',
            'config_scope': 'Store',
            'config_scope_id': merchantInfo.cloudMerchantStoreId,
            'merchant_id': merchantInfo.cloudMerchantId
          }
        };
        let [recommendWholeEnableValue, recommendSimilarEnableValue, recommendUgcEnableValue] = await Promise.all([api
          .getRecommendConfigValue(wholeEnableParams), api.getRecommendConfigValue(similarEnableParams), api
          .getRecommendConfigValue(ugcEnableParams)
        ]);
        if (recommendWholeEnableValue.code == 1000 && recommendWholeEnableValue.data.value == true) {
          that.wholeEnableConfig = true;
          const recommendWholeNumberValue = await api.getRecommendConfigValue({
            method: 'GET',
            query: {
              'config_client_id': 'efcloud',
              'config_path': 'recommend/' + that.recommendModule + '/whole_number',
              'config_scope': 'Store',
              'config_scope_id': merchantInfo.cloudMerchantStoreId,
              'merchant_id': merchantInfo.cloudMerchantId
            }
          });
          if (recommendWholeNumberValue.code == 1000) {
            that.wholeNumberConfig = recommendWholeNumberValue.data.value;
            let d_wholevalue = 0;
            d_wholevalue = parseInt(that.wholeNumberConfig) - that.recommendWhole.length;
            if (d_wholevalue > 0) {
              that.recommendLists(d_wholevalue);
            }
          }
        }
        if (recommendSimilarEnableValue.code == 1000 && recommendSimilarEnableValue.data.value == true) {
          that.smilarEnableConfig = true;
          const recommendSimilarNumberValue = await api.getRecommendConfigValue({
            method: 'GET',
            query: {
              'config_client_id': 'efcloud',
              'config_path': 'recommend/' + that.recommendModule + '/similar_number',
              'config_scope': 'Store',
              'config_scope_id': merchantInfo.cloudMerchantStoreId,
              'merchant_id': merchantInfo.cloudMerchantId
            }
          });
          if (recommendSimilarNumberValue.code == 1000) {
            that.smilarNumberConfig = recommendSimilarNumberValue.data.value;
            let d_similarvalue = 0;
            d_similarvalue = parseInt(that.smilarNumberConfig) - that.recommendSimilar.length
            if (d_similarvalue > 0) {
              that.d_similarvalue = d_similarvalue;
              if (that.classId != undefined && that.classId != null && that.classId != '') {
                that.getSimilarItems(that.classId, that.d_similarvalue)
              } else {
                that.getClassId(that.ccCode)
              }
            }
          }
        }
        if (recommendUgcEnableValue.code == 1000 && recommendUgcEnableValue.data.value == true) {
          that.ugcEnableConfig = true;
        }
      },

      // 获取推荐数量
      recommendConfigNum: async function() {
        var that = this;
        let merchantInfo = uni.getStorageSync(MERCHANT_INFO);
        const getrecommendNum = await api.getRecommendConfigValue({
          method: 'GET',
          query: {
            'config_client_id': 'efcloud',
            'config_path': 'recommend/number',
            'config_scope': 'Store',
            'config_scope_id': merchantInfo.cloudMerchantStoreId,
            'merchant_id': merchantInfo.cloudMerchantId
          }
        })
        if (getrecommendNum.code == 1000) {
          let recommendNum = getrecommendNum.data.value;
          let d_wholevalue = 0;
          let d_similarvalue = 0;

          d_wholevalue = recommendNum - that.recommendWhole.length;
          d_similarvalue = recommendNum - that.recommendSimilar.length

          if (d_wholevalue > 0) {
            that.recommendLists(d_wholevalue);
          }

          if (d_similarvalue > 0) {
            that.d_similarvalue = d_similarvalue;
            if (that.classId != undefined && that.classId != null && that.classId != '') {
              that.getSimilarItems(that.classId, that.d_similarvalue)
            } else {
              that.getClassId(that.ccCode)
            }

          }
        }
      },

      // 获取搭配推荐商品 sku_codes对应frontCode，scenes：cart/pdp
      recommendLists: async function(num) {
        let that = this;
        let merchantInfo = uni.getStorageSync(MERCHANT_INFO);
        let type = 'item';
        let Lists = await api.getRecommendList({
          method: 'GET',
          query: {
            "scenes": "pdp",
            "sku_codes": that.ccCode,
            "merchant_id": merchantInfo.cloudMerchantId,
            "store_id": merchantInfo.cloudMerchantStoreId,
            "num": num,
            "must": 'TRUE',
          }
        })
        if (Lists.code === 1) {
          let recom_item = [];
          recom_item = Lists.data.products;
          for (let i in recom_item) {
            that.recommendWhole.push(JSON.parse(recom_item[i]))
          }

          if (that.recommendWhole.length > 0) {
            that.showWholeRecommend = true;
          }
        }

      },

      // 根据sku获取分类id
      getClassId: async function(q) {
        let that = this;
        let merchantInfo = uni.getStorageSync(MERCHANT_INFO)
        if (q != '' && q != null && q != undefined) {
          that.$commonFunction.doSearchGoods('', '', 1, 1, '', q, '', '', '', '', '').then((res) => {
            that.classIdArr = res.data.content[0].classId || []
            for (let j in that.classIdArr) {
              that.getSimilarItems(that.classIdArr[j], that.d_similarvalue)
            }
          }).catch((err) => {
            that.showLoaded = false
          })
          // const recomItems = await api.getGoodsList({
          //   query: {
          //     q:q,
          //     merchant_id: merchantInfo.cloudMerchantId,
          //     store_id: merchantInfo.cloudMerchantStoreId,
          //     page_no: 1,
          //     page_size: 1,
          //   }
          // })
          // if (recomItems.code === 1000) {
          //   that.classIdArr = recomItems.data.content[0].classId
          //   for(let j in that.classIdArr){
          //     that.getSimilarItems(that.classIdArr[j],that.d_similarvalue)
          //   }
          // }
        }

      },

      // 同类推荐商品
      getSimilarItems: async function(cateClassId, page_size) {
        let that = this;
        let customerInfo = uni.getStorageSync('customerInfo');
        let memberDetails = uni.getStorageSync('memberDetails') || getApp().globalData.memberDetails
        let merchantInfo = uni.getStorageSync(MERCHANT_INFO)
        if (cateClassId != '' && cateClassId != null && cateClassId != undefined) {

          that.$commonFunction.doSearchGoods(cateClassId, '', 1, page_size, '', '', '', '', '', '', '').then((
          res) => {

            if (res.data.total > 0) {
              var s_item = res.data.content;
            }

            for (var i in s_item) {
              if (that.recommendSimilar.length < page_size) {
                that.recommendSimilar.push(s_item[i])
              }
            }

            // 根据valueId去重
            if (that.recommendSimilar.length > 0) {
              that.showSmilarRecommend = true
              for (var i = 0; i < that.recommendSimilar.length; i++) {
                for (var j = i + 1; j < that.recommendSimilar.length; j++) {
                  if (that.recommendSimilar[i].valueId == that.recommendSimilar[j]
                    .valueId) { //第一个等同于第二个，splice方法删除第二个
                    that.recommendSimilar.splice(j, 1);
                    j--;
                  }
                }
              }
            }

            for (let z in that.recommendSimilar) {
              if (that.recommendSimilar[z].itemId == that.goodsId) {
                that.recommendSimilar.splice(z, 1)
              }
            }

            // 策略价格
            var s_item = [];
            for (var i in that.recommendSimilar) {
              s_item = that.recommendSimilar[i];
              if (!!s_item.strategies) {
                that.$commonFunction.priceRulesDeal(s_item.strategies).then(res => {
                  if (res.price !== 0) {
                    s_item.price = res.price
                  }
                  if (res.rulesArr.length > 0) {
                    s_item.rulesArr = res.rulesArr
                  }
                })
                // let result = await getApp().priceRulesDeal(s_item.strategies)
                // if(result.price !== 0) {
                //   s_item.price = result.price
                // }
                // if(result.rulesArr.length > 0) {
                //   s_item.rulesArr = result.rulesArr
                // }
              }
              // var strategyIdArr = [];
              // for (var j in s_item['strategies']) {
              //   var s_strategy = s_item['strategies'][j]
              //   if (s_strategy['strategyStartTime'] != '' && s_strategy['strategyStartTime'] != '' && s_strategy[
              //       'strategyEndTime'] != null && s_strategy['strategyEndTime'] != null &&
              //     s_strategy['strategyPrice'] != null && s_strategy['strategyPrice'] != '' && Number(s_strategy[
              //       'strategyPrice']) > 0) {
              //     var endTimestamp = Date.parse(s_strategy['strategyEndTime'].replace(/-/g, '/')); // 为了兼容IOS，需先将字符串转换为'2018/9/11 9:11:23' 返回'2018-9-12 9:11:23'的时间戳
              //     var startTimestamp = Date.parse(s_strategy['strategyStartTime'].replace(/-/g, '/'));
              //     var timestamp = (new Date()).getTime();
              //     if (timestamp >= startTimestamp && timestamp < endTimestamp) {
              //       strategyIdArr.push(s_strategy)
              //     } else {}
              //   }
              // }
              // if (strategyIdArr != '') {
              //   s_item['price'] = strategyIdArr[0].strategyPrice;
              // }

              var customPromotionTags = [];
              for (var t in s_item['promotionTagList']) {
                var tagItem = s_item['promotionTagList'][t];
                if (tagItem.promotionType == 'custom_tag') {
                  customPromotionTags.push(tagItem);
                }
              }

              let tempTagList = customPromotionTags.slice()
              tempTagList.sort((a, b) => {
                return a.sortOrder - b.sortOrder
              })

              that.recommendSimilar[i]['customPromotionTags'] = tempTagList;

            }
          }).catch((err) => {
            // that.showLoaded = false
          })
          //   const recomItems = await api.getGoodsList({
          //     query: {
          //       class_id: cateClassId || '',
          //       merchant_id: merchantInfo.cloudMerchantId,
          //       store_id: merchantInfo.cloudMerchantStoreId,
          //       page_no: 1,
          //       page_size: page_size,
          // group_id: customerInfo.groupId || 0,
          // member_level_id: memberDetails.memberLevelId || 0,
          // member_status: memberDetails.isActive || 'Inactive'
          //     }
          //   })
          //   if (recomItems.code === 1000) {
          //     if(recomItems.data.total > 0){
          //      var s_item = recomItems.data.content;
          //     }

          //     for (var i in s_item) {
          //       if(that.recommendSimilar.length < page_size){
          //         that.recommendSimilar.push(s_item[i])
          //       }
          //     }

          //     // 根据valueId去重
          //     if(that.recommendSimilar.length > 0){
          //       that.showSmilarRecommend = true
          //       for(var i=0; i<that.recommendSimilar.length; i++){
          //           for(var j=i+1; j<that.recommendSimilar.length; j++){
          //             if(that.recommendSimilar[i].valueId==that.recommendSimilar[j].valueId){         //第一个等同于第二个，splice方法删除第二个
          //                 that.recommendSimilar.splice(j,1);
          //                 j--;
          //             }
          //           }
          //       }
          //     }

          //     for(let z in that.recommendSimilar){
          //       if(that.recommendSimilar[z].itemId == that.goodsId){
          //         that.recommendSimilar.splice(z,1)
          //       }
          //     }

          //     // 策略价格
          //     var s_item = [];
          //     for (var i in that.recommendSimilar) {
          //       s_item = that.recommendSimilar[i];
          //          if(!!s_item.strategies) {
          //            let result = await getApp().priceRulesDeal(s_item.strategies)
          //            if(result.price !== 0) {
          //              s_item.price = result.price
          //            }
          //            if(result.rulesArr.length > 0) {
          //              s_item.rulesArr = result.rulesArr
          //            }
          //          }
          //       // var strategyIdArr = [];
          //       // for (var j in s_item['strategies']) {
          //       //   var s_strategy = s_item['strategies'][j]
          //       //   if (s_strategy['strategyStartTime'] != '' && s_strategy['strategyStartTime'] != '' && s_strategy[
          //       //       'strategyEndTime'] != null && s_strategy['strategyEndTime'] != null &&
          //       //     s_strategy['strategyPrice'] != null && s_strategy['strategyPrice'] != '' && Number(s_strategy[
          //       //       'strategyPrice']) > 0) {
          //       //     var endTimestamp = Date.parse(s_strategy['strategyEndTime'].replace(/-/g, '/')); // 为了兼容IOS，需先将字符串转换为'2018/9/11 9:11:23' 返回'2018-9-12 9:11:23'的时间戳
          //       //     var startTimestamp = Date.parse(s_strategy['strategyStartTime'].replace(/-/g, '/'));
          //       //     var timestamp = (new Date()).getTime();
          //       //     if (timestamp >= startTimestamp && timestamp < endTimestamp) {
          //       //       strategyIdArr.push(s_strategy)
          //       //     } else {}
          //       //   }
          //       // }
          //       // if (strategyIdArr != '') {
          //       //   s_item['price'] = strategyIdArr[0].strategyPrice;
          //       // }

          //       var customPromotionTags = [];
          //       for (var t in s_item['promotionTagList']) {
          //       	var tagItem = s_item['promotionTagList'][t];
          //       	if(tagItem.promotionType == 'custom_tag'){
          //       		customPromotionTags.push(tagItem);
          //       	}
          //       }

          //       let tempTagList = customPromotionTags.slice()
          //       tempTagList.sort((a, b) => {
          //       	return a.sortOrder - b.sortOrder
          //       })

          //       that.recommendSimilar[i]['customPromotionTags'] = tempTagList;

          //     }


          //   }
        }
      },



      // 记录点击同类推荐商品
      clickRecommendItem: async function(item_id, sku_code) {
        let that = this;
        let merchantInfo = uni.getStorageSync(MERCHANT_INFO)
        let clickRecommData = await api.userClickRecommendItem({
          method: 'POST',
          query: {
            "item_id": item_id,
            "sku_code": sku_code,
            "merchant_id": merchantInfo.cloudMerchantId,
            "store_id": merchantInfo.cloudMerchantStoreId,
            "access_key": that.access_key,
          }
        })
        if (clickRecommData.code === 1) {

        }
      },


      // 点击推荐商品跳转到pdp
      jumpPage(e) {
        let that = this;
        let itemId = e.currentTarget.dataset.itemid;
        let skucodes = e.currentTarget.dataset.skucodes;
        let valueId = e.currentTarget.dataset.valueid;
        let valueName = e.currentTarget.dataset.valuename;
        let classId = e.currentTarget.dataset.classid;

        that.clickRecommendItem(itemId, skucodes)
        uni.navigateTo({
          url: "/pages/item/item?id=" +
            itemId +
            "&valueId=" +
            valueId +
            '&valueName=' +
            valueName +
            "&categoryName=" +
            that.categoryName +
            "&classIdArr=" +
            classId +
            "&skucodes=" +
            skucodes
        })
      },

    }
  }
</script>

<style lang="less">
  /* 商品列表-标题 */
  .col2Img {
    text-align: center;
    margin-top: 50rpx;

    h6 {
      margin-bottom: 50rpx;
      font-size: 36rpx;
      font-family: syHeavy;
    }

    .goodsList {
      border: none;
      margin-bottom: 10rpx;
      padding-bottom: 0
    }

    /* 商品列表 */
    .goodsList {
      display: flex;
      flex-wrap: wrap;
      padding-bottom: 150rpx;
      margin-bottom: 90rpx;
      border-bottom: 1px solid #444;
      justify-content: space-between;
      // .gItem:nth-child(even){margin-left:4%}

      .gItem {
        width: 348rpx;
        margin-bottom: 40rpx;
        text-align: center;

        .img {
          display: block;
        }

        image {
          width: 348rpx;
        }

        .name {
          margin-top: 18rpx;
          font-size: 24rpx;
          font-family: sySansSC_ExtraLight;
        }

        .recommendPrice {
          text-align: center;
          margin-top: 6rpx;
          font-size: 28rpx;
          display: flex;
          justify-content: center;
          text-align: center;

          .linePrice {
            color: #ccc;
            text-decoration: line-through;
            font-family: syExtraLight;
            display: inline-block;
          }

          .nowPrice {
            float: left;
            font-family: syHeavy;
            color: #f208c2;
            margin-left: 18rpx;
            text-decoration: none;
          }

          .price {
            color: #444;
            text-align: center;
          }
        }

        .color {
          margin-top: 6rpx;

          image {
            width: 20rpx;
            height: 20rpx;
            display: inline-block;
            margin-left: 14rpx
          }

          image:first-child {
            margin: 0;
          }

        }


      }

    }

  }

  // UGC样式
  .mos {
    margin-top: 40rpx;

    .title {
      margin-bottom: 40rpx;
      font-size: 36rpx;
      text-align: center;
      font-family: syHeavy;
    }

    .pView {
      padding-bottom: 30rpx;
    }

    .imgView {
      display: flex;
      flex-wrap: wrap;

      .item {
        width: 48%;
        margin-top: 3%;
      }

      .item:nth-child(even) {
        margin-left: 3%;
      }

      .item image {
        display: block;
      }
    }
  }

  // UGC样式
</style>
